package com.wanjia.seal.manager.service.Impl;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.wanjia.seal.manager.entity.BankInfoTB;
import com.wanjia.seal.manager.entity.OperatorUser;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class TokenServiceA {
    /**
     * 过期时间5分钟
     */
    private static final long EXPIRE_TIME =  60 * 5 * 60 * 1000;

    public String getToken2(BankInfoTB BankInfoTB) {
        Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME);
        String token="";
        token= JWT.create().withAudience(BankInfoTB.getBankID()) // 将 OperatorID 保存到 token 里面
                .withExpiresAt(date) //五分钟后token过期
                .sign(Algorithm.HMAC256(BankInfoTB.getBankID())); // 以 password 作为 token 的密钥
        return token;
    }


}